﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModuleCalendarAdd.aspx.cs"
    Inherits="news_ModuleCalendarAdd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../js/jquery-ui-1.7.3.custom.min.js" type="text/javascript"></script>
    <link href="../css/jquery-ui-1.7.3.custom.css" rel="stylesheet" type="text/css" />
    <script src="../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var selectValue = new Array();
            $('#dialog').dialog({
                autoOpen: false,
                modal: true,
                width: 400,
                buttons: {
                    "取消": function () {
                        var chks = $('#cblStock input[type=checkbox]');
                        for (var i = 0; i < chks.length; i++) {
                            chks[i].checked = false;
                            for (var j = 0; j < selectValue.length; j++) {
                                if (chks[i].value == selectValue[j]) {
                                    chks[i].checked = true;
                                }
                            }
                        }
                        $(this).dialog("close");
                    },
                    "确定": function () {
                        var cbk = $('#cblStock input[type=checkbox]');
                        $("#txtStock").html('');
                        var txt = '';
                        var val = "";
                        for (var i = 0; i < cbk.length; i++) {
                            var chk = cbk[i]
                            if (chk.checked) {
                                txt += $(chk).parent().children("label").html() + ",";
                                val += $(chk).val() + ",";
                            }
                        }
                        if (txt.length == 0) {
                            alert("必须选择一个新闻类型");
                            return;
                        }
                        if (val.length > 0) {
                            val = val.substring(0, val.length - 1);
                            $("#hidSelectValue").val(val);
                        }
                        if (txt.length > 0) {
                            txt = txt.substring(0, txt.length - 1);
                        }
                        $("#txtStock").html(txt);
                        $(this).dialog("close");
                    }
                }
            });
            $('#btnStock').click(function () {
                var hot = $('#ddlModule').val();
                var dt = $('#txtTime').val();
                if (hot == "") {
                    alert('请选择热门板块');
                    return false;
                }
                if (dt == "") {
                    alert("请选择日期");
                    return false;
                }
                var cbk = $('#cblStock input[type=checkbox]');
                var vals = $("#hidSelectValue").val().split(",");
                for (var i = 0; i < vals.length; i++) {
                    for (var j = 0; j < cbk.length; j++) {
                        if (cbk[j].value == vals[i]) {
                            cbk[j].checked = true;
                        }
                    }
                }
                selectValue.length = 0;
                for (var i = 0; i < cbk.length; i++) {
                    if (cbk[i].checked) {
                        selectValue[selectValue.length] = $(cbk[i]).val();
                    }
                }

                $('#dialog').dialog('open');
            });
            $('#btnSubmit').click(function () {
                var hot = $('#ddlModule').val();
                var reason = $('#txtReason').val();
                var stock = $('#txtStock').val();
                if (hot == "") {
                    alert('热门板块不能为空');
                    return false;
                }
                if (reason == "") {
                    alert('关注理由不能为空');
                    return false;
                }
                if (stock == "") {
                    alert('可关注股票不能为空');
                    return false;
                }
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="hidSelectValue" runat="server" />
    <div id="divModule" align="center">
        <table style="width: 637px">
            <tr>
                <th>
                    热门板块
                </th>
                <td colspan="2" align="left">
                    <asp:DropDownList ID="ddlModule" runat="server" OnSelectedIndexChanged="ddlModule_SelectedIndexChanged"
                        AppendDataBoundItems="True" AutoPostBack="True" Height="19px" 
                        Width="148px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <th>
                    板块日期
                </th>
                <td colspan="2" align="left">
                    <asp:TextBox ID="txtTime" runat="server" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <th>
                    可关注股票
                </th>
                <td colspan="2" align="left">
                    <asp:TextBox ID="txtStock" runat="server" TextMode="MultiLine" Width="400px" Height="80" ReadOnly="true"></asp:TextBox><input
                        id="btnStock" type="button" style="width:74px" value="选择股票"  class="common_button"  />
                </td>
            </tr>
            <tr>
                <th>
                    关注理由
                </th>
                <td colspan="2" align="left">
                    <asp:TextBox ID="txtReason" runat="server" TextMode="MultiLine" Width="400px" Height="80"></asp:TextBox>
                    <asp:Button ID="btnSubmit" runat="server" Text="提交" Width="74px" class="common_button"
                        OnClick="btnSubmit_Click" />
                </td>
            </tr>
        </table>
    </div>
    <div id="dialog" title="提示消息" style="display:none">
        <p id="content" style="text-align: center;">
            <asp:CheckBoxList ID="cblStock" runat="server" RepeatDirection="Horizontal" RepeatColumns="4">
            </asp:CheckBoxList>
        </p>
    </div>
    </form>
</body>
</html>
